package com.zareal.feign;

import com.zareal.enums.GlobalErrorCode;
import com.zareal.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class SystemFeignClientFallbackFactory implements FallbackFactory<SystemFeignClient> {
    @Override
    public SystemFeignClient create(Throwable throwable) {
        return new SystemFeignClient() {
            @Override
            public JSONResult get(Long id) {
                return JSONResult.error(GlobalErrorCode.SYSTEM_QUERY_ERROR.getErrorMessage());
            }
        };
    }
}
